<template>
    <a-modal
            :width="800"
            :visible="visible"
            :confirmLoading="confirmLoading"
            @cancel="handleCancel"
    >
    <a-spin :spinning="confirmLoading">
            <a-row>
              <a-col :span="24">
                <w-file-upload
                        class="avatar-uploader"
                        text="上传"
                        :multipleFlag="false"
                        v-model="avatar1"
                        bizPath="companyPic"
                        @ok="uploadOk"
                >
                </w-file-upload>
          </a-col>
            </a-row>

    </a-spin>

        <template slot="footer">
             <a-button @click="handleCancel" style="margin-right: .8rem">取消</a-button>

            <a-button @click="handleSubmit" type="primary" :loading="confirmLoading">确定</a-button>
        </template>
    </a-modal>
</template>

<script>
  import { getAction, postAction } from '@/api/manage'
  import WFileUpload from '../../../components/WxFileUpload/WFileUpload'
  export default {
    name: 'fileUpload',
    components: {
        WFileUpload
    },
    data () {
      return {
        visible: false,
        confirmLoading: false,
        formInfo: {
          linkMan: undefined,
          linkTel: undefined,
          province: undefined,
          city: undefined,
          area: undefined,
          address: undefined,
          medicalCard: undefined,
          childName: undefined,
          zycs: undefined,
          depart: undefined,
          zydate: undefined,
          cydate: undefined,
          zhlx: undefined,
          hzcard: undefined,
          parentcard: undefined,
          parentcard2: undefined,
          parentcard3: undefined,
          identitycode: undefined,
          copyContent: undefined,
          pageNumber: undefined,
          copyNumber: undefined,
          copyMoney: undefined,
          codeMoney: undefined,
          code: undefined,
          checkState: undefined,
          moneyState: undefined,
          moveState: undefined,
          operateNo: undefined,
          submitDate: undefined,
          checkDate: undefined,
          checkRemark: undefined,
          tradeNo: undefined,
          codeNo: undefined,
          tradeCode: undefined,
          addmoneyDate: undefined,
          addmoneyTime: undefined,
          principal: undefined,
          moveDate: undefined,
          saveDate: undefined,
          qsgx: undefined,
          profit: undefined,
          tflag: undefined,
          wx: ''
        },
          avatar1:undefined,
        drawerWidth: 800,
        url: {
          saveFile: '/system/user/savefile',
          getInfo: '/system/user/info'
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit()
      },
      edit () {
        this.visible = true
      },
        uploadOk(){
            this.avatar1s=JSON.stringify(this.avatar1)
            console.log("xxx"+this.avatar1)
        },
        // 确定
      handleSubmit () {
        // 触发表单验证
            if(this.avatar1!=undefined) {
                this.confirmLoading = true
                postAction(this.url.saveFile, { 'avatarl': this.avatar1 }).then(res => {
                    this.$message.success(res.content)
                    this.close()
                }).finally(() => {
                    this.confirmLoading = false
                })
            }else{
                this.$message.error("请上传文件")
          }
      },
      // 关闭
      handleCancel () {
        this.close()
      },
      close () {
        /*this.$refs.ruleForm.resetFields()
        this.$objToReset(this.avatar1)*/
          this.avatar1=undefined;
        this.$emit('close')
        this.visible = false
      },
      editorOk (val) {
        this.formInfo.content = val
      }
    }
  }
</script>
